package com.aidex.biz.service.impl;

import com.aidex.biz.domain.AccountType;
import com.aidex.biz.mapper.AccountTypeMapper;
import com.aidex.biz.service.AccountTypeService;
import com.aidex.common.annotation.DataScope;
import com.aidex.common.core.service.BaseServiceImpl;
import com.aidex.common.utils.NumberUtils;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 系统账户类型Service业务层处理
 *
 * @author sean
 * @email 2074844820@qq.com
 * @date 2022-10-26
 */
@Service
@Transactional(readOnly = true)
public class AccountTypeServiceImpl extends BaseServiceImpl<AccountTypeMapper, AccountType> implements AccountTypeService {
    private static final Logger log = LoggerFactory.getLogger(AccountTypeServiceImpl.class);

    /**
     * 获取单条数据
     *
     * @param accountType 系统账户类型
     * @return 系统账户类型
     */
    @Override
    public AccountType get(AccountType accountType) {
        AccountType dto = super.get(accountType);
        return dto;
    }

    /**
     * 获取单条数据
     *
     * @param id 系统账户类型id
     * @return 系统账户类型
     */
    @Override
    public AccountType get(String id) {
        AccountType dto = super.get(id);
        return dto;
    }


    /**
     * 查询系统账户类型列表
     *
     * @param accountType 系统账户类型
     * @return 系统账户类型
     */
    @Override
    @DataScope(userAlias = "a", deptAlias = "a")
    public List<AccountType> findList(AccountType accountType) {
        return super.findList(accountType);
    }

    /**
     * 分页查询系统账户类型列表
     *
     * @param accountType 系统账户类型
     * @return 系统账户类型
     */
    @Override
    @DataScope(userAlias = "a", deptAlias = "a")
    public PageInfo<AccountType> findPage(AccountType accountType) {
        return super.findPage(accountType);
    }

    /**
     * 保存系统账户类型
     *
     * @param accountType
     * @return 结果
     */
    @Override
    public boolean save(AccountType accountType) {
        return super.save(accountType);
    }


    /**
     * 删除系统账户类型信息
     *
     * @param accountType
     * @return 结果
     */
    @Override
    public boolean remove(AccountType accountType) {
        return super.remove(accountType);
    }

    /**
     * 批量删除系统账户类型
     *
     * @param ids 需要删除的系统账户类型ID
     * @return 结果
     */
    @Transactional(readOnly = false)
    @Override
    public int deleteAccountTypeByIds(String[] ids) {
        return mapper.deleteAccountTypeByIds(ids);
    }

    /**
     * 获取最大编号
     *
     * @param accountType 系统账户类型
     * @return 结果
     */
    @Override
    public int findMaxSort(AccountType accountType) {
        return NumberUtils.nextOrder(mapper.findMaxSort(accountType));
    }

    @Override
    public Map<String, String> getUserAccountInfo(AccountType accountType) {
        return mapper.getUserAccountInfo(accountType);
    }
}
